package controllers

import (
	"lottery_code/conf"
	"lottery_code/models"
	"lottery_code/services"
)

func (api *LuckyApi)prize(prizeCode int,limitBlack bool) *models.ObjGiftPrize{
	giftService:=services.NewGiftService()
	var prizeGift *models.ObjGiftPrize
	giftList:=giftService.GetAllUse(true)
	for _,gift:=range giftList{
		if gift.PrizeCodeA<=prizeCode&&gift.PrizeCodeB>=prizeCode{
			//中奖编码区间满足，说明可以中奖
			if !limitBlack||gift.Gtype<conf.GtypeGiftSmall{
				prizeGift=&gift
				break
			}
		}
	}
	return prizeGift
}
